package ch.sv7.tool.dbmanager.db.difference;

import ch.sv7.tool.dbmanager.db.ColumnSchema;
import ch.sv7.tool.dbmanager.db.TableSchema;

public abstract class AbstractColumnDifference extends AbstractTableDifference {

	private ColumnSchema actualColumnSchema;
	private ColumnSchema expectedColumnSchema;

	public AbstractColumnDifference(ColumnSchema expectedColumnSchema, ColumnSchema actualColumnSchema) {
		super(expectedColumnSchema == null ? null : expectedColumnSchema.getTable(), 
				actualColumnSchema == null ? null : actualColumnSchema.getTable());
		this.actualColumnSchema = actualColumnSchema;
		this.expectedColumnSchema = expectedColumnSchema;
	}

	public AbstractColumnDifference(TableSchema expectedTableSchema, TableSchema actualTableSchema, ColumnSchema expectedColumnSchema, ColumnSchema actualColumnSchema) {
		super(expectedTableSchema, actualTableSchema);
		this.actualColumnSchema = actualColumnSchema;
		this.expectedColumnSchema = expectedColumnSchema;
	}

	/**
	 * @return the actualColumnSchema
	 */
	public ColumnSchema getActualColumnSchema() {
		return actualColumnSchema;
	}

	/**
	 * @return the expectedColumnSchema
	 */
	public ColumnSchema getExpectedColumnSchema() {
		return expectedColumnSchema;
	}

	public String getMessage() {
		if (getActualColumnSchema() != null){
			return super.getMessage() + " Column [" + getActualColumnSchema().getName() + "]";
		} else {
			return super.getMessage() + " Column [" + getExpectedColumnSchema().getName() + "]";
		}
	}

	
}
